<div class="container">
    <h2>{{this.flag=="0"?"用户追加":this.flag=="1"?"用户编辑":"用户删除"}}</h2>
    <form [formGroup]="registerForm" (ngSubmit)="onSubmit()">
      <div class="form-group">
        <label for="name">Username:</label>
        <input type="text" class="form-control" id="name" formControlName="name">
        <div *ngIf="registerForm.get('name')?.invalid && (registerForm.get('name')?.touched || registerForm.get('name')?.dirty)">
          <small class="text-danger" *ngIf="registerForm.get('name')?.errors?.['required']">
            Username is required.
          </small>
        </div>
      </div>
      <div class="form-group">
        <label for="password">Password:</label>
        <input type="password" class="form-control" id="password" formControlName="password">
        <div *ngIf="registerForm.get('password')?.invalid && (registerForm.get('password')?.touched || registerForm.get('password')?.dirty)">
          <small class="text-danger" *ngIf="registerForm.get('password')?.errors?.['required']">
            Password is required.
          </small>
        </div>
      </div>
      <div class="form-group">
        <label for="email">Email:</label>
        <input type="email" class="form-control" id="email" formControlName="email">
        <div *ngIf="registerForm.get('email')?.invalid && (registerForm.get('email')?.touched || registerForm.get('email')?.dirty)">
          <small class="text-danger" *ngIf="registerForm.get('email')?.errors?.['required']">
            Email is required.
          </small>
          <small class="text-danger" *ngIf="registerForm.get('email')?.errors?.['email']">
            Please enter a valid email address.
          </small>
        </div>
      </div>
      <div class="form-group">
        <label for="phonenumber">Phone Number:</label>
        <input type="tel" class="form-control" id="phonenumber" formControlName="phonenumber">
        <div *ngIf="registerForm.get('phonenumber')?.invalid && (registerForm.get('phonenumber')?.touched || registerForm.get('phonenumber')?.dirty)">
          <small class="text-danger" *ngIf="registerForm.get('phonenumber')?.errors?.['required']">
            Phone number is required.
          </small>
        </div>
      </div>
      <div class="form-group">
        <label for="userimg">Profile Image URL (optional):</label>
        <input type="text" class="form-control" id="userimg" formControlName="userimg">
      </div>
      <button type="submit" class="btn btn-primary" >{{this.flag=="0"?"保存":this.flag=="1"?"保存":"删除"}}</button>
      <button type="button" class="btn btn-secondary ms-2" (click)="goBack()">Return</button>
    </form>
  </div>
  